﻿
Chenxin.UI.DataDictionaryMgr=Chenxin.extend(Chenxin.UI.PageCommon,{
	actionUrl:'/service/DataDictionaryMgr.ashx',
	pageSize:15,
	createGrid:function(){		
		return new Chenxin.UI.Pagination({
			actionUrl:this.actionUrl+'?op=getlist',
			id:'datadictionary',
			renderTo:'div_datadictionarylist',
			autoLoad:this.autoLoadGrid
		});
	},
	/*
	addBlock:function(){
		if(!this.addBlockWin){
			this.addBlockWin=new Chenxin.UI.BlockAddForm({
				scope:this,
				saveSucc:function(data,msg){
					this.grid.reload();	
				},
				afterGetFormJson:function(model){
					//model.ItemIndex=this.addBlockWin.itemIndex;
					model.ItemKey='System.Block';
				}
			});
		}
		
		if(this.addBlockWin.show()){
			this.addBlockWin.setTitle('添加板块');
			this.addBlockWin.reset();
		}
	},*/
	initEvent:function(){		
		var _this=this;
		$("#btn_add").live("click", function(){
			_this.add();
			_this.form.reset();
		});
		$("#btn_del").live("click", function(){
			_this.del();
		});
		// $('#btn_addblock').click(function(){
			// _this.addBlock();
		// });
		
		
		$('.tr_datadictionary').live('click',function(){	
			$('.tr_datadictionary,.selected_orgbgcolor').each(function(){
				$(this).removeClass('selected_orgbgcolor');	
			});
			_this.currentId=this.id;
			$(this).toggleClass('selected_orgbgcolor');	
			//$(':checkbox,[name="input_chk"],[value="'+this.id+'"]').attr('checked','checked');
		});
		
		$('.tr_datadictionary').live('mouseover',function(){
			$(this).toggleClass('orgbgcolor');
		});
		$('.tr_datadictionary').live('mouseout',function(){
			$(this).toggleClass('orgbgcolor');
		});
	},
	createForm:function(){
		return new Chenxin.UI.DataDictionaryInfoForm({
			scope:this,
			saveSucc:function(data,msg){
				this.grid.reload();	
			}
		});
	},
	createSearch:function(){
		return new Chenxin.UI.DataDictionarySearch({
			scope:this
		});
	},
	initComponent:function(){
		Chenxin.UI.DataDictionaryMgr.superclass.initComponent.call(this);
	}
});

Chenxin.UI.DataDictionaryInfoForm=Chenxin.extend(Chenxin.UI.FormCommon,{
	actionUrl:'/service/DataDictionaryMgr.ashx',
	id:'datadictionaryWin',
	renderTo:'jqm_datadictionary',
	title:'添加参数',
	jqmWidth:400,
	createForm:function(){
		return Chenxin.UI.FormCommon.dataDictionaryInfoForm(this.id);
	},
	customerFormVal:function(model){
		if(model.ItemKey=='System.Block'||model.ItemKey=='System.Region'){
			alert('请在区域板块管理处添加区域板块');
			return false;
		}
		return true;
	},
	initFormValidator:function(){
	    //权限编号验证
        $('#'+this.id+'_itemvalue').formValidator({ validatorgroup:this.id,
            onshow: "请输入参数名称", onfocus: "请输入参数名称", oncorrect: " "
        }).inputValidator({
            min: 1, empty: { emptyerror: "参数名称不能为空!" }, onerror: "参数名称不能为空!"
        });
        $('#'+this.id+'_itemtype').formValidator({ validatorgroup:this.id,
            onshow: "请输入参数类型", onfocus: "请输入参数类型", oncorrect: " "
        }).inputValidator({
            min: 0, empty: { emptyerror: "请输入正整数!" }, onerror: "请输入正整数!"
        }).functionValidator({
            fun: function(val, elem) {
				return val.isNum();
			},onerror: "请输入数字"
        });
		
		$('#'+this.id+'_itemindex').formValidator({ validatorgroup:this.id,
            onshow: "请输入排序", onfocus: "请输入排序", oncorrect: " "
        }).inputValidator({
            min: 0, empty: { emptyerror: "请输入正整数!" }, onerror: "请输入正整数!"
        }).functionValidator({
            fun: function(val, elem) {
				return val.isNum();
			},onerror: "请输入数字"
        });
		
	},	
	initEvent:function(){			
		var _this=this;
		$('#'+this.id+'_Save').live('click',function(){
			_this.save();
		});
		$('#'+this.id+'_Cancle').live('click',function(){
			_this.hide();
		});	
	},
	createComboList:function(){		
		this.dataItem=new Chenxin.UI.Combo({
			actionUrl:'/service/DataDictionaryMgr.ashx?op=getdataitemcombolist',
			autoLoad:true,
			colNum:2,
			pageSize:20,
			colWidth:120,
			type:'new',
			containerId: '#'+this.id+'_dataitem',
			name:'ItemKey',
			hasPage:true,
			required:true			
		});
	

		var city = new Chenxin.UI.StructCombo({
            containerId: '#'+this.id+'_City',
            name: 'CityId',
            autoLoad: true,
            required:true,
            tbxWidth:90,
			inModelType:'all',
			txtModelName:'City',
			param:{op:'getcity'},
			required:true,
			onSelected:function(){
				if(this.getValue()==this.defVal){
					company.clearItems();
				}else{
					company.param.fatherid=this.getValue();
					company.reload();
				}
			}
		});		
		var company = new Chenxin.UI.StructCombo({
            containerId: '#'+this.id+'_Company',
            name: 'CompanyId',
            autoLoad: true,
			required:true,
            required:true,
            tbxWidth:90,
			inModelType:'all',
			txtModelName:'Company',
			param:{op:'getcompany'}
		});	
		return [this.dataItem,city,company];
	},
	initComponent:function(){
		Chenxin.UI.DataDictionaryInfoForm.superclass.initComponent.call(this);
	}
});


/**
*@description 板块添加
*
Chenxin.UI.BlockAddForm=Chenxin.extend(Chenxin.UI.FormCommon,{
	actionUrl:'/service/DataDictionaryMgr.ashx',
	id:'blockWin',
	title:'添加板块',
	renderTo:'jqm_block',
	jqmWidth:400,
	createForm:function(){
		return Chenxin.UI.FormCommon.blockAddForm(this.id);
	},
	initEvent:function(){			
		var _this=this;
		$('#'+this.id+'_Save').live('click',function(){
			_this.save();
		});
		$('#'+this.id+'_Cancle').live('click',function(){
			_this.hide();
		});	
	},	
	initFormValidator:function(){
	    //权限编号验证
        $('#'+this.id+'_itemvalue').formValidator({ validatorgroup:this.id,
            onshow: "请输入参数名称", onfocus: "请输入参数名称", oncorrect: " "
        }).inputValidator({
            min: 1, empty: { emptyerror: "参数名称不能为空!" }, onerror: "参数名称不能为空!"
        });
        $('#'+this.id+'_itemtype').formValidator({ validatorgroup:this.id,
            onshow: "请输入参数类型", onfocus: "请输入参数类型", oncorrect: " "
        }).inputValidator({
            min: 0, empty: { emptyerror: "请输入正整数!" }, onerror: "请输入正整数!"
        }).functionValidator({
            fun: function(val, elem) {
				return val.isNum();
			},onerror: "请输入数字"
        });
		
		
		
	},
	getItemIndex:function(region){
		if(!region){
			this.itemIndex=undefined;
			return;
		}
	
		var _this=this;
		Chenxin.ajax({
			url:this.actionUrl,
			data:{op:'getitemindex',region:region},
			type:'get',
			onSuccess:function(data,msg){
				_this.itemIndex=data.ItemIndex;
			}
		});
	},
	createComboList:function(){	
		var _this=this;
		var city = new Chenxin.UI.StructCombo({
            containerId: '#'+this.id+'_City',
            name: 'CityId',
            autoLoad: true,
            required:true,
            tbxWidth:90,
			inModelType:'all',
			txtModelName:'City',
			param:{op:'getcity'},
			onSelected:function(){
				if(this.getValue()==this.defVal){
					region.clearItems();
				}else{
					region.param.cityid=this.getValue();
					region.reload();
				}
			}
		});	
		
		var region = new Chenxin.UI.ParameterCombo({
            name: 'Region',
            containerId: '#'+this.id+'_Region',
            key: 'System.Region',
            tbxWidth:90,
            inModelType: 'none',
			autoLoad:false,
			required:true
        });
		region.param.filter='bycity';
		
	
		return [city,region];
	},
	initComponent:function(){
		Chenxin.UI.BlockAddForm.superclass.initComponent.call(this);
	}
});*/

Chenxin.UI.DataDictionarySearch=Chenxin.extend(Chenxin.UI.SearchCommon,{
	id:'dataDictionary_search',
	initEvent:function(){
		var _this=this;
		$('#btn_search').live('click',function(){
			_this.scope.reloadGrid();
		});
	},
	createComboList:function(){	
		var dataItem=new Chenxin.UI.Combo({
			actionUrl:'/service/DataDictionaryMgr.ashx?op=getdataitemcombolist',
			autoLoad:true,
			colNum:4,
			colWidth:120,
			tbxWidth:120,
			containerId: '#community_SearchItemKey',
			name:'itemkey',
			required:true			
		});
		
		//城市
		var city=new Chenxin.UI.StructCombo({
			param:{op:'getcity'},
			containerId:'#community_SearchCity',
			name:'cityid',
			tbxWidth:120,
			onSelected:function(){
				if(this.getValue()==this.defVal){
					company.clearItems();
				}else{
					company.param.fatherid=this.getValue();
					company.reload();
				}
			}
		});
		var company=new Chenxin.UI.StructCombo({
			autoLoad:false,
			param:{op:'getcompany'},
			tbxWidth:120,
			name:'companyid',
			containerId:'#community_SearchCompany'
		});
		
		
		
		return [city,company,dataItem];
	},
	initComponent:function(){
		Chenxin.UI.DataDictionarySearch.superclass.initComponent.call(this);
	}
});


/**
*@description 楼栋DIV
*@method 提交按钮的处理方法
*
Chenxin.UI.FormCommon.blockAddForm=function(comboIdPrefix){
        return '<table class="tbl_f"><tr><th><span class="isfilled">*</span>板块名称：</th><td><input type="text" class="inputbox_n fl" id="'+comboIdPrefix+'_itemvalue" name="ItemValue" style="width:120px;"/><div id="'+comboIdPrefix+'_itemvalueTip" style="float:left; margin-left: 5px; width: 120px; height: 26px; line-height: 26px; text-align: left;" class="fl"></div></td></tr><tr><th>参数类型：</th><td><input type="text" class="inputbox_n fl" name="ItemType" id="'+comboIdPrefix+'_itemtype" style="width:120px;"/><div id="'+comboIdPrefix+'_itemtypeTip" style="float:left; margin-left: 5px; width: 120px; height: 26px; line-height: 26px; text-align: left;" class="fl"></div></td></tr><tr><th><span class="isfilled">*</span>城市：</th><td><div style="z-index: 901; margin-right: 5px;" id="'+comboIdPrefix+'_City" class="SelectWrapSingle fl"></td></tr><tr><th><span class="isfilled">*</span>区域：</th><td><div style="z-index: 900; margin-right: 5px;" id="'+comboIdPrefix+'_Region" class="SelectWrapSingle fl"></td></tr><tr><th></th><td align="right"><div style="float:right; margin-right:15px;"><a id="' + comboIdPrefix + '_Save" class="btn_n fl" href="#"><span>确定</span></a><a id="' + comboIdPrefix + '_Cancle"  class="btn_n fl" href="#"><span>取消</span></a></div></td></tr></table>'
};
*/

/**
*@description 楼栋DIV
*@method 提交按钮的处理方法
*/
Chenxin.UI.FormCommon.dataDictionaryInfoForm=function(comboIdPrefix){
        return '<table class="tbl_f"><tr><th><span class="isfilled">*</span>城市：</th><td><div style="z-index: 906; margin-right: 5px;" id="'+comboIdPrefix+'_City" class="SelectWrapSingle fl"></td></tr><tr><th><span class="isfilled">*</span>公司：</th><td><div style="z-index: 905; margin-right: 5px;" id="'+comboIdPrefix+'_Company" class="SelectWrapSingle fl"></td></tr><tr><th><span class="isfilled">*</span>参数标识:</th><td><div id="'+comboIdPrefix+'_dataitem" style="z-index:902; margin-right: 5px;" class="SelectWrapSingle validator_build"></div></td></tr><tr><th><span class="isfilled">*</span>参数名称：</th><td><input type="text" class="inputbox_n fl" id="'+comboIdPrefix+'_itemvalue" name="ItemValue" style="width:120px;"/><div id="'+comboIdPrefix+'_itemvalueTip" style="float:left; margin-left: 5px; width: 120px; height: 26px; line-height: 26px; text-align: left;" class="fl"></div></td></tr><tr><th>参数类型：</th><td><input type="text"  id="'+comboIdPrefix+'_itemtype" class="inputbox_n fl" name="ItemType" style="width:120px;"/><div id="'+comboIdPrefix+'_itemtypeTip" style="float:left; margin-left: 5px; width: 120px; height: 26px; line-height: 26px; text-align: left;" class="fl"></div></td></tr><tr><th>排序：</th><td><input id="'+comboIdPrefix+'_itemindex" type="text" class="inputbox_n fl" name="ItemIndex" style="width:120px;"/><div id="'+comboIdPrefix+'_itemindexTip" style="float:left; margin-left: 5px; width: 120px; height: 26px; line-height: 26px; text-align: left;" class="fl"></div></td></tr><tr><th></th><td align="right"><div style="float:right; margin-right:15px;"><input type="hidden" name="CommunityId"/><a id="' + comboIdPrefix + '_Save" class="btn_n fl" href="#"><span>确定</span></a><a id="' + comboIdPrefix + '_Cancle"  class="btn_n fl" href="#"><span>取消</span></a></div></td></tr></table>'
};

$(document).ready(function(){
	var dataMgr=new Chenxin.UI.DataDictionaryMgr();
});





















